package com.teamclub.app.sconfs

import org.springframework.boot.autoconfigure.AutoConfigureAfter
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.{Bean, Configuration, DependsOn}
import org.springframework.web.filter.DelegatingFilterProxy

@Configuration
class FilterConfig {
  @Bean
  def shiroFilterRegistration: FilterRegistrationBean = {
    val registration = new FilterRegistrationBean
    registration.setFilter(new DelegatingFilterProxy("shiroFilter"))
    //该值缺省为false，表示生命周期由SpringApplicationContext管理，设置为true则表示由ServletContainer管理
    registration.addInitParameter("targetFilterLifecycle", "true")
    registration.setEnabled(true)
    registration.setOrder(Integer.MAX_VALUE - 1)
    registration.addUrlPatterns("/*")
    registration
  }
}
